/**
 * DOMErrorManager.java 21 juil. 07
 *
 * Copyright (c) 2007 windu.2b <jcaddie@windu2b.org>. All Rights Reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
package org.windu2b.jcaddie.io.xml;

import org.xml.sax.*;

/**
 * @author Francescu Garoby
 * 
 */
public class DOMErrorsManager implements ErrorHandler
{

	/**
	 * 
	 */
	public DOMErrorsManager()
	{
		// TODO Constructeur à compléter
	}




	protected String message( SAXParseException e )
	{
		String message = "Message : " + e.getMessage() + "\n";
		message += "Ligne " + e.getLineNumber() + ", colonne "
		        + e.getColumnNumber() + "\n" + "Public id : " + e.getPublicId()
		        + "\n" + "System id : " + e.getSystemId();

		return message;
	}




	protected void printSAXException( SAXParseException e )
	{
		if ( e.getException() != null ) e.getException().printStackTrace();
	}




	/**
	 * @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
	 */
	public void error( SAXParseException saxpe ) throws SAXException
	{
		printSAXException( saxpe );
	}




	/**
	 * @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
	 */
	public void fatalError( SAXParseException saxpe ) throws SAXException
	{
		String message = "*** Erreur fatale ***\n";
		message += message( saxpe );
		SAXException se = new SAXException( message, saxpe );
		throw se;
	}




	/**
	 * @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
	 */
	public void warning( SAXParseException saxpe ) throws SAXException
	{
		printSAXException( saxpe );
	}
}